package com.vids.utils;

import java.security.MessageDigest;

public class DegistUtils {

    public static String getMD5(String source) {
	// 用来将字节转换成 16 进制表示的字符
	char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
	try {
	    MessageDigest md = MessageDigest.getInstance("MD5");
	    md.update(source.getBytes());
	    byte[] encryptStr = md.digest();
	    char str[] = new char[16 * 2];
	    int k = 0;
	    for (int i = 0; i < 16; i++) {
		byte byte0 = encryptStr[i];
		str[k++] = hexDigits[byte0 >>> 4 & 0xf];
		str[k++] = hexDigits[byte0 & 0xf];
	    }
	    return new String(str);
	} catch (Exception e) {
	    e.printStackTrace();
	}
	return "";
    }



}
